<template>
  <div class="history-container">
    <el-form ref="formRef" :model="pamars" inline>
      <el-form-item label="发放时间">
        <el-date-picker v-model="timer" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="datetimerange" range-separator="-" start-placeholder="开始时间"
          end-placeholder="结束时间" @change="timerChange">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="success" @click="getDataList()">查询</el-button>
        <el-button type="warning" @click="resetPamars()">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" row-key="Id" border stripe style="width: 100%">
      <el-table-column type="index" align="center" width="80px" label="序号">
      </el-table-column>
      <el-table-column prop="point_price" align="center" label="当日积分价值">
        <template slot-scope="scoped">
          <div>
            {{ isToFixed(scoped.row.point_price, 8) }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="give_away_handling_fee_ratio" align="center" label="转赠手续费">
        <template slot-scope="scoped">
          <div>
            {{ isToFixed(scoped.row.give_away_handling_fee_ratio, 8) }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="admin_username" align="center" label="操作人">
      </el-table-column>
      <el-table-column prop="create_time" align="center" label="修改时间">
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pamars.page" :page-sizes="[10, 20, 50, 100]"
      :page-size="pamars.limit" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
  </div>
</template>

<script>
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      timer: null,
      pamars: {
        page: 1,
        limit: 10,
        start_time: null,
        end_time: null
      },
      tableData: [],
      totalPage: 0
    }
  },
  created () {
    this.getList()
  },
  methods: {
    getList () {
      seviceApi.getIntegralConfigList(this.pamars).then(res => {
        if (res && res.data.code == 200) {
          this.tableData = res.data.page.list
          this.totalPage = res.data.page.totalCount
        }
      })
    },
    timerChange (e) {
      console.log(e)
      if (e) {
        this.pamars.start_time = e[0]
        this.pamars.end_time = e[1]
      } else {
        this.pamars.start_time = null
        this.pamars.end_time = null
      }
    },
    // 每页数
    sizeChangeHandle (val) {
      this.pamars.limit = val
      this.getList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.pamars.page = val
      this.getList()
    },
    // 查询
    getDataList () {
      this.pamars.page = 1
      this.getList()
    },
    resetPamars () {
      this.timer = null
      this.pamars.start_time = null
      this.pamars.end_time = null
      this.$refs.formRef.resetFields()
      this.getDataList()
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
